// pages/index/index.js
Page({

  data: {
    cateList: ['关注', '本地', '经济', '军事', '教育', '搞笑', '体育'],
    currentIndex: 0,
    newsList: [
      {
        title: '微信小程序已经成为新零售最佳的落地点',
        image: '../../images/1.png',
        from: '物理系',
        public_time: '2021-03-22'
      },
      {
        title: '微信小程序已经成为新零售最佳的落地点',
        image: '../../images/2.png',
        from: '物理系',
        public_time: '2021-03-22'
      },
      {
        title: '微信小程序已经成为新零售最佳的落地点',
        image: '../../images/3.png',
        from: '物理系',
        public_time: '2021-03-22'
      }
    ]
  },

  changeIndex: function(e) {
    this.setData({
      currentIndex: e.currentTarget.dataset.index
    })
  },

  onLoad: function (options) {
    var that = this
    wx.getSetting({
      success: function(res) {
        if(res.authSetting['scope.userInfo'] === true) {
          wx.getUserInfo({
            lang: 'zh_CN',
            success: function (res) {
              console.log(res.userInfo)
              that.setData({
                userInfo: res.userInfo
              })
            }
          })
        } else {
          wx.navigateTo({
            url: '../userinfo/userinfo',
          })
        }
      }
    })
    
    
  },
})